import sys
# 补充其他文件夹路径，否则无法使用
sys.path.append("./code/Python/schedule-master")
sys.path.append("./code/Python/request")
from requestAreaHot import requestAreaHot
from requestLiveCount import requestLiveCount
from requestLOLHotHero import requestLOLHotHero
import schedule
import time
import threading
'定时任务'


# 获取分区热度
def areaHot():
    requestAreaHot()


# 获取直播数量
def liveCount():
    requestLiveCount()


# 获取英雄热度（由于目前数据太少了）
def heroCount():
    requestLOLHotHero()


def run_threaded(func):
    thread = threading.Thread(target=func)
    thread.start()


# 每小时00分的时候执行
schedule.every().hour.at(":00").do(run_threaded, areaHot)
schedule.every().hour.at(":00").do(run_threaded, liveCount)
schedule.every().hour.at(":00").do(run_threaded, heroCount)

while True:
    # 运行
    schedule.run_pending()
    # 一分钟看一次
    time.sleep(60)
